<script type="text/javascript">
$(document).ready(function(){
    $('#tahun_box').change(function(){
       if(document.getElementById("tahun_box").value == 0)window.location.href="<?php echo site_url('skim'); ?>"
       $.ajax({
                type: "POST",
                url: $("#program_form").attr('action'),
                data: $("#program_form").serialize(),
                success: function(data) {
                            $("select#box_program").html(data);
                }
            });
            return false;
    });
    
    $("#box_program").change(function(){
           if(document.getElementById("box_program").value == 0)window.location.href="<?php echo site_url('skim'); ?>"
           var loc1 = "<?php echo site_url('skim/skim_list'); ?>";
           var loc2 = loc1.concat("/");
           var loc3 = loc2.concat(document.getElementById("tahun_box").value);
           var loc4 = loc3.concat("/");
           var loc5 = loc4.concat(document.getElementById("box_program").value);
           window.location.href=loc5;
           document.getElementById("program_id").value = document.getElementById("box_program").value;
    });
});
</script>
<div class="kontent_box">
    <div class="kontent_panel">
    <div class="reg_input">
    <div><h3>Daftar Skim</h3></div>
    <form id="program_form" method="post" action="<?php echo site_url('program/get_program_by_tahun'); ?>">
        <select id="tahun_box" name="tahun_box">
            <option value="0" <?php if($tahun_id == -1) echo 'selected' ?> >Pilih Tahun</option>
                <?php foreach ($list_tahun as $row) { ?>
                <option value="<?php echo $row['TAHUN_ID'];?>" <?php if($tahun_id == $row['TAHUN_ID'])echo 'selected'; ?>><?php echo $row['TAHUN_NAMA'];?></option>
                <?php } ?>
        </select>
    </form>
    <select id="box_program" name="program">
        <option value="0" <?php if($program_id == -1) echo 'selected' ?>>Pilih Program</option>
        <?php foreach($program_list as $row) { ?>
        <?php echo '<option value="'.$row['PROGRAM_ID'].'"'; ?>
        <?php if($program_id == $row['PROGRAM_ID']) echo 'selected'; ?>
        <?php echo '>'.$row['PROGRAM_NAMA'].'</option>'; ?>
        <?php } ?>
    </select>          
    <br />
    
    <table border="1">
        <tr>
            <th>NAMA PROGRAM</th>
            <th>KODE SKIM</th>
            <th>NAMA SKIM</th>
            <th></th>
        </tr>
        <?php foreach($skim_list as $row) { ?>
        <tr>
            <td><?php echo $row['PROGRAM_NAMA']; ?></td>
            <td><?php echo $row['SKIM_KODE']; ?></td>
            <td><?php echo $row['SKIM_NAMA']; ?></td>
            
            <td>
                <a href="<?php echo base_url().'index.php/skim/detail/'.$row['SKIM_ID'] ?>">DETAIL</a>
                <a href="<?php echo base_url().'index.php/skim/delete/'.$row['SKIM_ID'] ?>">DELETE</a>
            </td>
        </tr>
        <?php } ?>
    </table>
    </div>
</div>